#!/usr/bin/perl 
# lastten.pl
use warnings;
use strict;

print "Reading...";
 
open READ, "myfile" or die "Cannot open: $! \n";
my @lines = <READ>;
print "$. lines read \n";
close READ;

if ($#lines < 9) {
   exit;
}

print "Writing...";
open WRITE, "> myfile" or die "Cannot write: $! \n";
foreach (@lines[?10..?1]) {
   print WRITE $_;
}
print "done \n";
close WRITE;
